package com.fmdj.customer.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import com.fmdj.common.util.CommonResult;

import com.fmdj.customer.controller.form.InsertCommentForm;
import com.fmdj.customer.service.OrderCommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

@RestController
@RequestMapping("/comment")
@Tag(name = "OrderCommentController", description = "订单评论模块web接口")
@Slf4j
public class OrderCommentController {

    @Autowired
    private OrderCommentService orderCommentService;

    @PostMapping("/insertComment")
    @Operation(summary = "更新账单(同时更新订单以及插入一条分账记录)")
    @SaCheckLogin
    public CommonResult insertComment(@RequestBody @Valid InsertCommentForm form) {
        long customerId = StpUtil.getLoginIdAsLong();
        form.setCustomerId(customerId);
        int rows = orderCommentService.insertComment(form);
        return CommonResult.ok().put("'rows", rows);
    }
}
